package org.blogwu.learn.multithread.chapter2.demo9;

public class Main {
    static int i = 0;

    public static void main(String[] args) throws InterruptedException {
        AddThread addThread = new AddThread();
        AddThread addThread1 = new AddThread();
        addThread.start();
        addThread1.start();
        addThread.join();
        addThread1.join();
        System.out.println(i);
    }
}

class AddThread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            synchronized (AddThread.class) {
                Main.i++;
            }
        }
    }
}
